
function pretty_button(callback, title, width, height, extra_style){
	v = '<a href="javascript:' + callback 
	v += '" class="pretty_button" style="line-height:' + height + 'px;height:' + height + 'px;width:' 
	v += width + 'px;' + extra_style + '">' + title + '</a>'
	return v
}

function get_link_values(key){
	if(window.location.search == 0) return 'none'
	search_term = window.location.search.replace('?','')
	pairs = search_term.split('&')
	pair_map = {}
	for(i in pairs){
		key_val = pairs[i].split('=')
		pair_map[key_val[0]] = key_val[1]
	}
	if(pair_map.hasOwnProperty(key)){
		return pair_map[key]
	}else{
		return 'none'
	}
}

function translate_number_to_day(num){
	if(num == 0) return 'sunday'
	if(num == 1) return 'monday'
	if(num == 2) return 'tuesday'
	if(num == 3) return 'wednesday'
	if(num == 4) return 'thursday'
	if(num == 5) return 'friday'
	if(num == 6) return 'saturday'
}

function empty_string(value, msg){
	if(value.length == 0){
		alert(msg)
		return true
	}
	return false
}

function standardize_time(hour, min){
	am_pm = 'am'
	if(hour > 11){
		am_pm = 'pm'
	}
	if(hour > 12){
		hour = hour - 12
	}

	hour = hour + ''
	min = min + ''

	if(min.length == 1){
		min = '0' + min
	}
	return hour + ':' + min + am_pm
}

function specialToSafe(cString) {
//use this in the future encodeURI()
//use this in the future dencodeURI()
//	encodeURIComponent() for special characters
	//return Base64.encode(cString)


	if(cString == null) return cString
	if(cString == undefined) return cString


	cString = cString.replace(/'/g, "|===|")
	cString = cString.replace(/&/g, "|amps|")
	cString = cString.replace(/#/g, "|pnd|")
	cString = cString.replace(/@/g, "|at|")
	cString = cString.replace(/%/g, "|pcnt|")
	cString = cString.replace(/\(/g, "|lbr|")
	cString = cString.replace(/\)/g, "|rbr|")
	cString = cString.replace(/\*/g, "|star|")
	cString = cString.replace(/\[/g, "|lbra|")
	cString = cString.replace(/\]/g, "|rbra|")
	cString = cString.replace(/\?/g, "|qst|")
	cString = cString.replace(/\:/g, "|col|")
	cString = cString.replace(/\;/g, "|scol|")
	cString = cString.replace(/\,/g, "|com|")
	cString = cString.replace(/\{/g, "|lcbr|")
	cString = cString.replace(/\}/g, "|rcbr|")
	cString = cString.replace(/\"/g, "|dqu|")
	//cString = cString.replace(/\//g, '|slash|')

	return cString
}

function SafeStringToSpecial(cString)
{
	if(cString == null) return cString
	if(cString == undefined) return cString

	//return Base64.decode(cString)

	cString = cString.replace(/\|===\|/g,"'")
	cString = cString.replace(/\|amps\|/g,   "&") 
	cString = cString.replace(/\|pnd\|/g,    "#") 
	cString = cString.replace(/\|at\|/g,     "@") 
	cString = cString.replace(/\|pcnt\|/g,   "%") 
	cString = cString.replace(/\|lbr\|/g,   "(") 
	cString = cString.replace(/\|rbr\|/g,   ")") 
	cString = cString.replace(/\|star\|/g,   "*") 
	cString = cString.replace(/\|lbra\|/g,   "[") 
	cString = cString.replace(/\|rbra\|/g,   "]") 
	cString = cString.replace(/\|qst\|/g,   "?") 
	cString = cString.replace(/\|col\|/g,   ":") 
	cString = cString.replace(/\|scol\|/g,   ";") 
	cString = cString.replace(/\|com\|/g,   ",") 
	cString = cString.replace(/\|lcbr\|/g,   "{") 
	cString = cString.replace(/\|rcbr\|/g,   "}") 
	cString = cString.replace(/\|dqu\|/g,   "\"") 
	cString = cString.replace(/\%20/g,   " ") 
	//cString = cString.replace('|slash|', '/')
	return cString
}

